﻿@page
@model Chino.IdentityServer.Pages.User.ExternalLoginsModel
@inject IStringLocalizer<Chino.IdentityServer.Pages.User.ExternalLoginsModel> L
@{
    Layout = "_UserLayout";
    ViewData["pageName"] = "externalLogin";
    ViewContext.ClientValidationEnabled = true;
}


<div class="card shadow mb-3">
    <div class="card-header">
        <h6 class="h6">@L["card_header_externalLogin"]</h6>
    </div>
    <div class="card-body">
        <table class="table">
            <tbody>
                @foreach (var login in Model.CurrentLogins)
                {
                    <tr>
                        <td id="@($"login-provider-{login.LoginProvider}")">@login.ProviderDisplayName</td>
                        <td>
                            @if (Model.ShowRemoveButton)
                            {
                                <form id="@($"remove-login-{login.LoginProvider}")" asp-page-handler="RemoveLogin" method="post">
                                    <div>
                                        <input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden" />
                                        <input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden" />
                                        <button type="submit" class="btn btn-primary" title="Remove this @login.ProviderDisplayName login from your account"><span class="oi oi-x"></span></button>
                                    </div>
                                </form>
                            }
                            else
                            {
                                @: &nbsp;
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>

@if (Model.OtherLogins?.Count > 0)
{
    <div class="card shadow mb-3">
        <div class="card-header">
            <h6 class="h6">@L["card_header_addExternalLogin"]</h6>
        </div>
        <div class="card-body">
            <form id="link-login-form" asp-page-handler="LinkLogin" method="post" class="form-horizontal">
                <div id="socialLoginList">
                    <p>
                        @foreach (var provider in Model.OtherLogins)
                        {
                            <button id="@($"link-login-button-{provider.Name}")" type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
                        }
                    </p>
                </div>
            </form>
        </div>
    </div>
}